package com.example.dialog.Activity;

import android.os.Bundle;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.dialog.R;
import com.example.dialog.Adapter.MessageAdapter;
import com.example.dialog.model.Message;
import java.util.ArrayList;
import java.util.List;

public class MessageActivity extends BaseActivity {
    private RecyclerView recyclerView;//用于高效地显示大量数据的滚动列表
    private MessageAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message);

        initView();
        setupBottomNavigation();
        loadTestData();
    }

    private void initView() {
        recyclerView = findViewById(R.id.messageRecyclerView);
        adapter = new MessageAdapter();
        //放置布局
        //LinearLayoutManager:用于在线性方向（垂直或水平）上排列列表项。
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        recyclerView.setAdapter(adapter);
    }

    private void loadTestData() {
        //加载信息，后期用数据库导入
        List<Message> messages = new ArrayList<>();
        messages.add(new Message(R.drawable.ic_launcher_background, "java大声", "知道了...我什么都会做的...", "星期一"));
        messages.add(new Message(R.drawable.baseline_search_24, "活动消息", "暗恒本分百万派息！一起挑战全网最高奖格", "星期日"));
        messages.add(new Message(R.drawable.baseline_search_24, "java讨论组", "\"momo\"加入了群聊", "星期日"));





        adapter.updateMessages(messages);
    }
}